package com.itheima.controller;

import com.itheima.client.dishpojo.vo.CategoryVo;
import com.itheima.common.JsonResult;
import com.itheima.service.ClientCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author wuzhiyong
 */
@RestController
@RequestMapping(value = "/category")
public class ClientCategoryController {
    @Autowired
    private ClientCategoryService clientCategoryService;

    /**
     * 分类列表
     * @return List<CategoryVo>
     */
    @GetMapping(value = "list")
    public JsonResult<List<CategoryVo>> categoryList() {

        List<CategoryVo> categoryVos = clientCategoryService.getDishType();
        if (categoryVos!=null){
            return JsonResult.success(categoryVos, null);
        }
        return JsonResult.error(null);
    }
}
